package org.yw.controller;

import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.yw.dto.Dto;
import org.yw.service.LoginService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * Created By YU WEI on 2020.09.07
 */
@RestController
@RequestMapping("/user/api/")
public class LoginController {
    @Resource
    private LoginService loginService;

    /**
     * 用户登陆
     * @param phone
     * @param password
     * @return
     */
    @PostMapping("p/login")
    public Dto doLogin(@RequestParam("phone")String phone,
                          @RequestParam("password")String password){
        Dto dto = loginService.doLogin(phone, password);
        return dto;
    }

    @PostMapping("v/queryUserInfoByToken")
    public Dto queryUserInfoByToken(HttpServletRequest request){
        Dto dto=loginService.queryUserInfoByToken(request);
        return dto;
    }

}
